<?php


namespace app\controllers;


 use app\models\request\ReqSubQuestion;
use app\models\UserDto;
use app\service\SuggestionService;

class SubQuestionController extends BaseJsonController
{

    /**
     * @param $req ReqSubQuestion
     * @param $userInfo UserDto
     * @return bool|mixed
     */
    public function doService($req,$userInfo)
    {
        $service  = new SuggestionService();
        $req->setUserId($userInfo->getUserId());
        $entity  = $service->getSubQuestion($req->getSuggestionId(),$req->getUserId());


        $arr = [];
        foreach ($entity as $r) {

            $arr[] = [
                "id"=>$r->getId(),
                "suggestion_id"=>$r->getSuggestionId(),
                "content"=>$r->getContent(),
                "type"=>$r->getType(),
                "create_time"=>$r->getCreateTime()
            ];
        }

        return $arr;
    }

    protected function injectionReq()
    {
        return new ReqSubQuestion();
    }

    public function needLogin(){
        return true;
    }


}